package com.dalei.vdsmanager.detection.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.dalei.vdsmanager.detection.model.LicensePlateType;

public class LicensePlateTypeDaoImpl extends HibernateDaoSupport implements
		LicensePlateTypeDao {

	@SuppressWarnings("unchecked")
	@Override
	public List<LicensePlateType> findLicensePlateTypes() {
		// TODO Auto-generated method stub
		String hql = "FROM LicensePlateType ORDER BY id";
		List<LicensePlateType> licensePlateTypes = getHibernateTemplate().find(hql);
		return licensePlateTypes;
	}

	@Override
	public LicensePlateType findLicensePlateTypeById(int id) {
		// TODO Auto-generated method stub
		Criteria criteria = getSession().createCriteria(LicensePlateType.class);
		criteria.add(Restrictions.eq("id", id));
		LicensePlateType licensePlateType = (LicensePlateType) criteria.uniqueResult();
		return licensePlateType;
	}

}
